<?php 
include('../Connections/KRAPPERCON.php');
include ("../Connections/Accesos.php");
?>
<div>
<input type="button" value="Consultar" onclick="showResTC();" />
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td >Fecha :</th>
  <td ><input name="t_fectc" id="t_fectc" value="<?php echo $hoy; ?>" class="tcal clsReq" type="text" maxlength="10" onKeyPress="if (event.keyCode==13) showResTC();"></th>  </tr>
  <tr>
    <td colspan="2" >
    <hr>
    <table width="100%" id="tbl_tc_tbl" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
        <th scope="col">Moneda Origen</th>
        <th scope="col">Moneda Destino</th>
        <th scope="col">Compra</th>
        <th scope="col">Venta</th>
      </tr>
      </thead>
      <tbody>
      </tbody>
    </table>        </tr>
  <tr>
    <td >
      <input type="button" name="btn_sav_tc" id="btn_sav_tc" value="Guardar Cambios" onClick="saveTC()" >
      
    <td >    </tr>
</table>
<script type="text/javascript">
function saveTC(){
var fecha = GEBI('t_fectc').value;
var items = '';

	$("#tbl_tc_tbl tbody tr").each(function(){
		var fila = $(this);
		var moneda = fila.attr('money');
		var dest  = 'PEN';
		var val1 = pFloat(fila.find('.tcVal1 input').val()); // Compra
		var val2 = pFloat(fila.find('.tcVal2 input').val()); // Venta
		items = items + moneda + '|' + dest + '|' + val1 + '|' + val2 + '#';
	});
	
	sendData('Procesos/Opers/OperTC.php',
	{
	oper : 'upd',
	items : items,
	fecha : fecha
	});
}

function showResTC(){
	$('#sp_loader').show();
	$("#tbl_tc_tbl tbody").load('Procesos/Opers/OperTC.php',{
		oper : 'get',
		fecha : GEBI('t_fectc').value
	},function()
		{
		$('#sp_loader').hide();
		}
	);
}

</script>

